<?php

/**
 * 首页
 * @author liuzilu <fotomxq@gmail.com>
 * @version 1
 * @package index
 */

?>

<!DOCTYPE html>
<html lang="zh-cn" dir="ltr" class="uk-height-1-1">

    <head>
        <meta charset="utf-8">
        <title>登录</title>
        <link rel="shortcut icon" href="app/assets/imgs/logo.ico" type="image/x-icon">
        <link rel="apple-touch-icon-precomposed" href="app/assets/imgs/logo.png">
        <link rel="stylesheet" href="app/assets/css/uikit.min.css">
        <link rel="stylesheet" href="app/assets/css/components/notify.min.css">
    </head>

    <body class="uk-height-1-1">

        <div class="uk-vertical-align uk-text-center uk-height-1-1">
            <div class="uk-vertical-align-middle" style="width: 250px;">

                <img class="uk-margin-bottom" width="140" height="120" src="app/assets/imgs/logo.png" alt="">

                <form class="uk-panel uk-panel-box uk-form" action="app/center/action-login.php" method="post">
                    <div class="uk-form-row">
                        <input class="uk-width-1-1 uk-form-large" type="text" placeholder="用户名" id="input-user" name="u">
                    </div>
                    <div class="uk-form-row">
                        <input class="uk-width-1-1 uk-form-large" type="password" placeholder="密码" id="input-passwd" name="password">
                        <input style="display:none;" type="text" name="p">
                    </div>
                    <div class="uk-form-row">
                        <a class="uk-width-1-1 uk-button uk-button-primary uk-button-large" href="#action-login">登录</a>
                    </div>
                    <div class="uk-form-row uk-text-small">
                        <label class="uk-float-left"><input type="checkbox" name="r"> 记住我</label>
                        <a class="uk-float-right uk-link uk-link-muted" href="#">忘记密码？</a>
                    </div>
                </form>

            </div>
        </div>
        <script src="app/assets/js/jquery.min.js"></script>
        <script src="app/assets/js/sha1.js"></script>
        <script src="app/assets/js/uikit.min.js"></script>
        <script src="app/assets/js/components/notify.min.js"></script>
        <script>
            var msg = "";
            <?php
            if(isset($_GET['login-faild']) && $_GET['login-faild'] === 'login-faild'){
                echo 'msg = "登陆失败，请输入正确的用户名和密码。";';
            }
            ?>
            $(function () {
                $('a[href="#action-login"]').click(function () {
                    if($('#input-user').val() && $('#input-passwd').val()){
                        var pd = hex_sha1($('#input-passwd').val());
                        $('#input-passwd').val(hex_sha1(hex_sha1(pd)));
                        $('input[name="p"]').val(pd);
                        $('form').submit();
                    }else{
                        UIkit.notify({
                            message : '登录失败，请输入有效的用户名和密码!',
                            status  : 'warning',
                            timeout : 5000,
                            pos     : 'top-center'
                        });
                    }
                });
                if(msg){
                    UIkit.notify({
                        message : msg,
                        status  : 'warning',
                        timeout : 5000,
                        pos     : 'top-center'
                    });
                }
            });
        </script>

    </body>

</html>